package object2;

import java.lang.Override;

/**
 * 面向对象编程（中级部分）练习
 */
public class Object2Exercise02 {

    public static void main(String[] args) {

        /*
            编写教师类
            1)属性：name age post salary
            2)方法：introduce()，输出一个教师的信息
            3)三个子类：教授类(Professor)、副教授类、讲师类
            4)工资级别：教授1.3 副教授1.2 讲师1.1，在三个子类里重写父类的introduce()
            5)定义并初始化一个教师对象完成基本能信息打印
         */

        Teacher t1 = new Teacher("张三", 20, "111", 4000);
        System.out.println(t1.introduce() + ",salary = " + t1.getSalary());

        Teacher t2 = new Professor("李四", 21, "222", 5000);
        System.out.println(t2.introduce());

        Teacher t3 = new AssociateProfessor("王五", 22, "333", 6000);
        System.out.println(t3.introduce());

        Teacher t4 = new Lecturer("赵六", 23, "444", 7000);
        System.out.println(t4.introduce());

    }
}

class Teacher {

    public String name;

    public int age;

    public String post;

    public double salary;

    public Teacher(String name, int age, String post, double salary) {
        this.name = name;
        this.age = age;
        this.post = post;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public String introduce() {
        return "name = " + name + ", age = " + age + ", post = " + post;
    }
}

class Professor extends Teacher {

    public double level = 1.3;

    public Professor(String name, int age, String post, double salary) {
        super(name, age, post, salary);
        this.salary = salary * this.level;
    }

    public double getLevel() {
        return level;
    }

    public void setLevel(double level) {
        this.level = level;
    }

    @Override
    public String introduce() {
        return super.introduce() + ", salary = " + salary;
    }
}

class AssociateProfessor extends Teacher {

    public double level = 1.2;

    public AssociateProfessor(String name, int age, String post, double salary) {
        super(name, age, post, salary);
        this.salary = salary * this.level;
    }

    public double getLevel() {
        return level;
    }

    public void setLevel(double level) {
        this.level = level;
    }

    @Override
    public String introduce() {
        return super.introduce() + ", salary = " + salary;
    }

}

class Lecturer extends Teacher {

    public double level = 1.1;

    public Lecturer(String name, int age, String post, double salary) {
        super(name, age, post, salary);
        this.salary = salary * this.level;
    }

    public double getLevel() {
        return level;
    }

    public void setLevel(double level) {
        this.level = level;
    }

    @Override
    public String introduce() {
        return super.introduce() + ", salary = " + salary;
    }
}